package data_management;

public class PatternSet{
	// data area
	private int 		_programType = -1;
	private PatternUnit _patternUnit = null;
	private String 		_programInfo = null;
	private String 		_patternNick = null;
	
	// error 
	public static final int NO_INSERTED_PATTERN = -1;
	
	// getter
	public String 	packageName()	{ return _programInfo; }
	public int 		type() 			{ return _programType; }
	public String 	nick()			{ return _patternNick; }
	
	public int 		keyOfHash()		{
		if(hasPatternUnit()) return _patternUnit.size();
		else return this.NO_INSERTED_PATTERN;
	}
	public int 		size()   		{ 
		if(hasPatternUnit()) return _patternUnit.size();
		else return this.NO_INSERTED_PATTERN; 
	}
	public long 	first()   		{ 
		if(hasPatternUnit()) return _patternUnit.get(0);
		else return this.NO_INSERTED_PATTERN; 
	}

	public String 	getProgramInfo()	{ return _programInfo;}
	public int 		getProgramType()	{ return _programType;}
	public PatternUnit getPatternUnit()	{ return _patternUnit;}
	public String 	getPatternNick()	{ return _patternNick;}
	
	// setter
	public void setProgramInfo(String info) {	_programInfo = info; }
	public void setProgramType(int type)	{   _programType = type; }
	public void setPatternNick(String nick)	{   _patternNick = nick; }
	public void setPatternUnit(PatternUnit unit) { _patternUnit = unit;}
	
	// flags
	private boolean deleted = false;
	public void delete(){
		deleted = true;
	}
	public boolean isDeleted(){
		return deleted;
	}
	
	// reset informations
	public void reset(){
		_programType = -1;
		this._patternNick = null;
		this._patternUnit = null;
		this._programInfo = null;
	}
	
	// boolean checking
	public boolean isCompleted(){
		// not completed
		if(_programType != -1 
		&& _patternUnit!=null 
		&& _programInfo!=null 
		&& _patternNick!=null){
			return true;
		}
		//completed
		else return false;
	}
	
	public boolean hasPatternUnit(){
		if(_patternUnit !=null) return true;
		else 					return false;
	}
	
	//Constructors
	public PatternSet(){}
	public PatternSet(PatternUnit pattern){
		this._patternUnit = pattern;
	}
	public PatternSet(String nick, PatternUnit pattern, String programInfo, int programType){
		this._patternUnit = pattern;
		this._programInfo = programInfo;
		this._programType = programType;
		this._patternNick = nick;
	}
}